<?php
        
	class PFlowManager
	{
		var $puzzle;
		
		function PFlowManager(&$owner)
		{
			$this->puzzle = $owner;
		}
		
		function executeController($controller, $extension = null)
		{
			if ($extension == null)
                	{
                		$extension = $this->puzzle->PEM->current_extension;
                	}
                	
                	if ($this->puzzle->PEM->existExtension($extension))
                	{
                		if ($this->existController($controller, $extension))
                		{
                			$controller = new PController($this->puzzle, $extension, $controller);
					$controller->execute();
				}
				else
				{
					die("Puzzle :: Error :: Controller $controller in extension $extension does not exist");
				}
			}
			else
			{
				die("Puzzle :: Error :: Loading controller $controller :: Extension $extension does not exist");
			}
		}
		
		function existController($view, $extension)
                {
                	$DS = $this->puzzle->config['DS'];
			
			if (file_exists($this->puzzle->config['dir_ext'] . $DS . $extension . $DS .  $this->puzzle->config['dir_ext_src'] . $DS . $this->puzzle->config['dir_ext_controllers'] . $DS . $view))
			{
				return true;
			}
			else
			{
				return false;
			}
                }
		
		function renderURL($url)
		{
			
		}
		
	}
        
?>
